#pragma once
#include <iostream>
#include "protocol.hpp"

class Calculator
{
public:
	Calculator() {}
	Response Execut(const Requst &req)
	{
		Response res;
		switch (req.Oper())
		{
		case '+':
			res.SetResult(req.X() + req.Y());
			 break;
		case '-':
			res.SetResult(req.X() - req.Y()); break;
		case '*':
			res.SetResult(req.X() * req.Y()); break;
		case '/':
			if(req.Y() == 0)
			{
				res.SetCode(1); break;
			}	
			res.SetResult(req.X() / req.Y()); break;
		case '%':
			if(req.Y() == 0)
			{
				res.SetCode(2); break;
			}
			res.SetResult(req.X() % req.Y()); break;
		default:
			res.SetCode(3); break;
		}

		return res;
	}
};